package com.vvv.myapiinterface.controller;

import com.vvv.myapiclientsdk.model.request.UserRequest;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;

/**
 * @author vvv
 * @date 2023-09-23 16 51
 * discription 模拟api接口
 */
@RestController
@RequestMapping("/name")
public class NameController {


    // TODO
    @GetMapping("/get")
    public String getNameByGet(String name) {
        return "GET你的名字是" + name;
    }

    // TODO
    @PostMapping("/post")
    public String getNameByPost(String name) {
        return "POST你的名字是" + name;
    }

    @PostMapping("/restful")
    public String getUserNameByPost(@RequestBody UserRequest userRequest, HttpServletRequest request) {
        String result = userRequest.getUserName() == null ? userRequest.getData().toString() : userRequest.getUserName();
        return "你的名字是" + result;
    }

}
